<template>
  <div class="mall-components-page">
    <el-card>
      <template #header>
        <span class="title">商城组件库</span>
      </template>

      <el-row :gutter="20">
        <el-col :span="8" v-for="comp in componentList" :key="comp.type">
          <el-card class="comp-card" shadow="hover">
            <div class="comp-icon" :style="{ background: comp.color }">
              <el-icon :size="48">
                <ShoppingCart v-if="comp.category === 'product'" />
                <PriceTag v-else-if="comp.category === 'marketing'" />
                <Picture v-else />
              </el-icon>
            </div>
            <h3>{{ comp.name }}</h3>
            <p>{{ comp.desc }}</p>
            <el-tag size="small">{{ comp.category }}</el-tag>
          </el-card>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ShoppingCart, PriceTag, Picture } from '@element-plus/icons-vue'

const componentList = ref([
  { type: 'banner', name: '轮播图', desc: '图片轮播展示', category: '基础组件', color: '#409eff' },
  { type: 'grid-nav', name: '魔方导航', desc: '图标导航网格', category: '基础组件', color: '#67c23a' },
  { type: 'product-list', name: '商品列表', desc: '商品网格展示', category: 'product', color: '#409eff' },
  { type: 'seckill', name: '秒杀活动', desc: '限时秒杀', category: 'marketing', color: '#f56c6c' },
  { type: 'coupon', name: '优惠券', desc: '领取优惠券', category: 'marketing', color: '#e6a23c' },
  { type: 'notice', name: '公告栏', desc: '滚动公告', category: '基础组件', color: '#909399' }
])
</script>

<style scoped>
.mall-components-page {
  padding: 20px;
  background: #f5f5f5;
  min-height: 100vh;
}

.title {
  font-size: 18px;
  font-weight: bold;
}

.comp-card {
  text-align: center;
  margin-bottom: 20px;
  transition: all 0.3s;
}

.comp-card:hover {
  transform: translateY(-5px);
}

.comp-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  color: white;
}

.comp-card h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.comp-card p {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: #606266;
}
</style>

